// IniFile.h: interface for the CIniReader class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_INIFILE_H__99976B4B_DBA1_4D1E_AA14_CBEB63042FD1__INCLUDED_)
#define AFX_INIFILE_H__99976B4B_DBA1_4D1E_AA14_CBEB63042FD1__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


#include <list>
#include <string>

class CIniReader  
{
public:
	// method to set INI file name, if not already specified 
	void setINIFileName(std::wstring strINIFile);
	
	// methods to return the lists of section data and section names
	std::list<std::wstring>* getSectionData(std::wstring strSection);
	std::list<std::wstring>* getSectionNames();
	
	// check if the section exists in the file
	bool sectionExists(std::wstring strSection);

	// updates the key value, if key already exists, else creates a key-value pair
	long setKey(std::wstring strValue, std::wstring strKey, std::wstring strSection);

	// give the key value for the specified key of a section
	std::wstring getKeyValue(std::wstring strKey,std::wstring strSection);
	
	// default constructor
	CIniReader()
	{
		m_sectionList = new std::list<std::wstring>;
		m_sectionDataList = new std::list<std::wstring>;
	}
	
	CIniReader(std::wstring strFile)
	{
		m_strFileName = strFile;
		m_sectionList = new std::list<std::wstring>;
		m_sectionDataList = new std::list<std::wstring>;
	}
	
	~CIniReader()
	{
		delete m_sectionList;
		delete m_sectionDataList;
	}
	
private:
	// lists to keep sections and section data
	std::list<std::wstring> *m_sectionDataList;
	std::list<std::wstring> *m_sectionList;
	
	std::wstring m_strSection;
	long m_lRetValue;
	
	// ini file name 
	std::wstring m_strFileName;
};

#define __W(x)      L ## x

#endif // !defined(AFX_INIFILE_H__99976B4B_DBA1_4D1E_AA14_CBEB63042FD1__INCLUDED_)
